#!/usr/bin/env bash


launchctl_prepare() {
  chmod 700 ~/dotfiles/ ~/dotfiles/LaunchAgents/ ~/dotfiles/LaunchAgents/*
}

launchctl_redis () {
  launchctl_prepare
  launchctl unload ~/library/LaunchAgents/com.dotfiles.redis.plist
  launchctl load ~/library/LaunchAgents/com.dotfiles.redis.plist
  sleep 0.5
  launchctl stop com.dotfiles.redis
  sleep 0.5
  launchctl start com.dotfiles.redis
  sleep 0.5
  launchctl list | grep redis
}
launchctl_mongo () {
  launchctl_prepare
  launchctl unload ~/library/LaunchAgents/com.dotfiles.mongodbstart.plist
  launchctl load ~/library/LaunchAgents/com.dotfiles.mongodbstart.plist
  sleep 0.5
  launchctl stop com.dotfiles.mongodbstart
  sleep 0.5
  launchctl start com.dotfiles.mongodbstart
  sleep 0.5
  launchctl list | grep mongodbstart
}

launchctl_virtualbox () {
  rsync -av ~/dotfiles/00my/install_mac_dir/LaunchDaemons/ /Library/LaunchDaemons/
  launchctl_prepare
  launchctl unload /Library/LaunchDaemons/org.virtualbox.vboxautostart.plist
  launchctl load /Library/LaunchDaemons/org.virtualbox.vboxautostart.plist
  sleep 0.5
  launchctl stop org.virtualbox.vboxautostart
  sleep 0.5
  launchctl start org.virtualbox.vboxautostart
  sleep 0.5
  launchctl list | grep virtualbox
}

gitlab_runner(){
  launchctl_prepare
  launchctl unload ~/library/LaunchAgents/com.dotfiles.mongodbstart.plist
  launchctl load ~/library/LaunchAgents/com.dotfiles.mongodbstart.plist
  /usr/local/bin/gitlab-runner uninstall
  /usr/local/bin/gitlab-runner install
  /usr/local/bin/gitlab-runner stop
  /usr/local/bin/gitlab-runner start
  sleep 1.5
  /usr/local/bin/gitlab-runner status
}


